<template>
  <div class="app-container">
    <el-form
      v-show="showSearch"
      ref="queryForm"
      :model="queryParams"
      size="small"
      :inline="true"
      label-width="68px"
    >
      <el-form-item label="关键字" prop="keyword">
        <el-input
          v-model="queryParams.projectName"
          placeholder="请输入名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      :<!--
        TODO: 项目列表
      -->
      <el-form-item label="项目" prop="projectId">
        <el-select
          v-model="queryParams.projectId"
          placeholder="请选择"
          filterable
          clearable
        >
          <el-option
            v-for="dict in [
              {
                value: 1,
                label: '体检',
              },
              {
                value: 2,
                label: '体2',
              },
            ]"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      :<!--
        TODO: 检查状态字典
      -->
      <el-form-item label="检查状态" prop="checkState">
        <el-select
          v-model="queryParams.checkState"
          placeholder="请选择"
          filterable
          clearable
        >
          <el-option
            v-for="dict in [
              {
                value: 1,
                label: '未检',
              },
              {
                value: 1,
                label: '已检',
              },
            ]"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      :<!--
        TODO: 审核状态字典
      -->
      <el-form-item label="审核状态" prop="state">
        <el-select
          v-model="queryParams.state"
          placeholder="请选择"
          filterable
          clearable
        >
          <el-option
            v-for="dict in [
              {
                value: 1,
                label: '未审',
              },
              {
                value: 2,
                label: '已审',
              },
              {
                value: 3,
                label: '图像',
              },
            ]"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="时间类型" prop="dateType">
        <el-select
          v-model="queryParams.dateType"
          placeholder="请选择"
          filterable
          clearable
        >
          <el-option
            v-for="dict in [
              {
                value: 1,
                label: '签到时间',
              },
              {
                value: 2,
                label: '检查时间',
              },
              {
                value: 3,
                label: '结果时间',
              },
              {
                value: 4,
                label: '图片时间',
              },
            ]"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="时间" prop="date">
        <el-date-picker
          v-model="queryParams.date"
          type="datetimerange"
          value-format="yyyy-MM-dd HH:mm:ss"
          range-separator="至"
          start-placeholder="开始时间"
          end-placeholder="结束时间"
          :disabled="!queryParams.dateType"
        />
      </el-form-item>

      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="list">
      <el-table-column label="名称" align="center" prop="num" />
      <el-table-column label="性别" align="center" prop="num" />
      <el-table-column label="年龄" align="center" prop="num" />
      <el-table-column label="未检项目" align="center" prop="num" />
      <el-table-column label="已检项目" align="center" prop="num" />
      <el-table-column label="结论" align="center" prop="num" />
      <el-table-column label="图像" align="center" prop="num" />
      <el-table-column label="状态" align="center" prop="num" />
      <el-table-column label="签到时间" align="center" prop="num" />
      <el-table-column label="扫码时间" align="center" prop="num" />
      <el-table-column label="结论时间" align="center" prop="num" />
      <el-table-column label="单位" align="center" prop="num" />
      <el-table-column label="分组" align="center" prop="num" />
      <el-table-column label="身份证号" align="center" prop="num" />
      <el-table-column label="备注" align="center" prop="num" />
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
        fixed="right"
      >
        <template slot-scope="scope">
          <el-button size="mini" type="text" @click="handleUpdate(scope.row)">
            编辑
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      :total="total"
      :page.sync="queryParams.skipCount"
      :limit.sync="queryParams.maxResultCount"
      @pagination="getList"
    />
  </div>
</template>

<script>
export default {
  name: "Project",
  components: {},
  data() {
    return {
      // 遮罩层
      loading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 检查项目表格数据
      list: [
        {
          num: 0,
        },
      ],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        skipCount: 0,
        maxResultCount: 10,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
      // tab切换
      activeName: "first",
      // 常用值关键字搜索
      normalCodeSearch: undefined,
    };
  },
  methods: {
    handleClick(tab, event) {
      console.log(tab, event);
    },
    /** 查询检查项目列表 */
    getList() {
      this.loading = true;
      // listProject(this.queryParams).then((response) => {
      //   this.projectList = response.rows;
      //   this.total = response.total;
      //   this.loading = false;
      // });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        categoryId: null,
        projectName: null,
        price: null,
        description: null,
        sexLimit: 2,
        ageLimit: null,
        address: null,
        isDel: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
      };
      // this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "新增";
    },
    /** 编辑按钮操作 */
    handleUpdate(row) {
      this.reset();
      // const id = row.id || this.ids;
      // getProject(id).then((response) => {
      //   this.form = response.data;
      //   this.open = true;
      //   this.title = "编辑";
      // });
      this.$router.push({
        path: "/sortingInspection/editSortForm",
        query: { registerId: row.id },
      });
    },
    /** 提交按钮 */
    submitForm() {
      // this.$refs["form"].validate((valid) => {
      //   if (valid) {
      //     if (this.form.id != null) {
      //       updateProject(this.form).then((response) => {
      //         this.$modal.msgSuccess("编辑成功");
      //         this.open = false;
      //         this.getList();
      //       });
      //     } else {
      //       addProject(this.form).then((response) => {
      //         this.$modal.msgSuccess("新增成功");
      //         this.open = false;
      //         this.getList();
      //       });
      //     }
      //   }
      // });
    },
    /** 删除按钮操作 */
    // handleDelete(row) {
    //   const ids = row.id || this.ids;
    //   this.$modal
    //     .confirm("是否确认删除？")
    //     .then(function () {
    //       return delProject(ids);
    //     })
    //     .then(() => {
    //       this.getList();
    //       this.$modal.msgSuccess("删除成功");
    //     })
    //     .catch(() => {});
    // },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "tijianyuyue/project/export",
        {
          ...this.queryParams,
        },
        `project_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>

<style>
</style>
